/**
 * NetworkInterfaceAPI.java
 * ************************** 
 * @date Mar 18, 2011
 * @author Michele Tamburini
 * 
 * **************************
 */
package gossipServices.network;

import messages.Message;
import gossipServices.basic.nodeDescriptors.NodeDescriptor;

/**
 * Description: 
 * The NetworkServicesAPI
 * is a layer between the service and the NetworkManager and 
 * offers a set of functions that translate
 * the calls of the service to the methods provided by the NetworkManager.
 * Generally each service may need it own NetworkServiceAPI.
 * Alternatively the service may handle itself the methods of the 
 * NetworkManager.
 *
 */
public interface NetworkServicesAPI{
	
	/**
	 * Sends the Message 'msg' to the node 'node' described by the
	 * NodeDescriptor. 
	 * @param msg : Message
	 * @param node : NodeDescriptor
	 */
	public void send(Message msg, NodeDescriptor node);
		
	/**
	 * Receive a Message from any sender.
	 * @return msg : Message
	 */
	public Message receive() throws InterruptedException;
	
	/**
	 * Receive a Message from the sender specified
	 * by the NodeDescriptor 'node'.
	 * @param node : NodeDescriptor
	 * @return msg : Message
	 */
	public Message receive(NodeDescriptor node) throws InterruptedException;
	
	/**
	 * Returns the node name.
	 * @return nodeName : String
	 */
	public String getNodeName();

	/**
	 * 
	 */
	public void clearReceivedMessages();
			
}
